# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gtkparasite

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=0.3.0.95.445cd7a
pkgrel=1
pkgdesc="GTK+ debugging and development tool for GTK+3 applications (mingw-w64)"
arch=('any')
url="http://chipx86.github.io/gtkparasite/"
license=("MIT")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
    "${MINGW_PACKAGE_PREFIX}-pkg-config"
    "${MINGW_PACKAGE_PREFIX}-gnome-common"
    "${MINGW_PACKAGE_PREFIX}-python2"
    "git")
depends=(
    "${MINGW_PACKAGE_PREFIX}-gtk3"
    "${MINGW_PACKAGE_PREFIX}-gtksourceview3"
    "${MINGW_PACKAGE_PREFIX}-python2-pygtk")
options=(!libtool strip staticlibs)
source=("${_realname}"::"git://github.com/chipx86/${_realname}.git"
    0003-check-for-sigaction.all.patch
    0004-use-glib-module.all.patch
    0005-w32-cpython-dll.all.patch)
md5sums=('SKIP'
         '4b0504f6a87842ce8f3f7598bcc27ff2'
         'b4e6d1e855b3a090d53e67280a4fdca8'
         'b9fc38d211ddbcb7c6dc4ae3703bd0d7')

pkgver() {
  cd "${_realname}"
  echo $(awk -F , '/^AC_INIT/ {print $2}' configure.ac | tr -d '[ ]').$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd "${srcdir}/${_realname}"
  # Replace old AutoMake macro with new one
  sed -i 's/AM_CONFIG_HEADER/AC_CONFIG_HEADERS/g' configure.ac
  patch -p1 -i ${srcdir}/0003-check-for-sigaction.all.patch
  patch -p1 -i ${srcdir}/0004-use-glib-module.all.patch
  patch -p1 -i ${srcdir}/0005-w32-cpython-dll.all.patch
}

build() {
  cd "${srcdir}/${_realname}"
  PYTHON=${MINGW_PREFIX}/bin/python2 ./autogen.sh \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}
  make
}

package() {
  cd "${srcdir}/${_realname}"
  make -j1 DESTDIR="$pkgdir" install
  
  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
